﻿using GN.Pay.Client.Services;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GN.Pay.Client
{
    /// <summary>
    /// 服务客户端
    /// </summary>
    public interface IServiceClient
    {
        /// <summary>
        /// 支付配置
        /// </summary>
        IPayConfigure PayConfigure { get; }

        /// <summary>
        /// 获取网关路径
        /// </summary>
        string GatewayPath { get; }

        /// <summary>
        /// 获取或设置编码
        /// </summary>
        Encoding Encoding { get; set; }

        /// <summary>
        /// 是否采用骆锋命名
        /// </summary>
        bool CamelCase { get; set; }

        /// <summary>
        /// 调用服务
        /// </summary>
        /// <param name="serviceName">服务名称</param>
        void CallService(string serviceName);

        /// <summary>
        /// 调用服务
        /// </summary>
        /// <typeparam name="TResult">结果类型</typeparam>
        /// <param name="serviceName">服务名称</param>
        /// <returns></returns>
        TResult CallService<TResult>(string serviceName);

        /// <summary>
        /// 调用服务
        /// </summary>
        /// <typeparam name="TRequest">请求类型</typeparam>
        /// <param name="serviceName">服务名称</param>
        /// <param name="request"></param>
        void CallService<TRequest>(string serviceName, TRequest request)
            where TRequest : class;

        /// <summary>
        /// 调用服务
        /// </summary>
        /// <typeparam name="TRequest"></typeparam>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="serviceName"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        TResult CallService<TRequest, TResult>(string serviceName, TRequest request) where TRequest : class;

        /// <summary>
        /// 获取交易申请服务
        /// </summary>
        ITradeApplyService TradeApplyService { get; }

        /// <summary>
        /// 获取交易查询服务
        /// </summary>
        ITradeQueryService TradeQueryService { get; }

        /// <summary>
        /// 获取商户会员服务
        /// </summary>
        IMerchantMemberService MerchantMemberService { get; }

        /// <summary>
        /// 获取通知
        /// </summary>
        INotifyService NotifyService { get; }

        /// <summary>
        /// 命令请求
        /// </summary>
        /// <param name="serviceName">服务名称</param>
        /// <param name="jsonParams">Json参数</param>
        /// <returns></returns>
        JToken CommandRequest(string serviceName, string jsonParams);
    }
}
